<?php 
    $url = new Url();
?>
<link type="text/css" href="<?=Yii::app()->params["urlRs"] ?>/js/jqueryui/jquery-ui-1.8.23.custom.css" rel="stylesheet" />
<script type="text/javascript" src="<?=Yii::app()->params["urlRs"] ?>/js/jqueryui/jquery-ui-1.8.23.custom.min.js"></script>

<div id="main" class="nosidebar">                    
    <div id="content">
        <h2>Cập nhật công việc</h2>

        <div class="box tabular">
            <div id="all_attributes">            

                <p>
                    <label for="issue_tracker_id">Chủ đề<span class="required"> *</span></label>
                    <select id="category_id" name="category_id">
                        <?php foreach($data_category as $row){ ?>
                            <option <?php if($data_task['task_category'] == $row['category_id'] ){echo "selected";} ?> value="<?php echo $row['category_id']; ?>"><?php echo $row['category_name']; ?></option>
                            <?php } ?>
                    </select>
                </p>

                <p>
                    <label for="issue_subject">Công việc<span class="required"> *</span></label>
                    <input id="task_name" name="task_name" size="80" type="text" value="<?php echo $data_task['task_name']; ?>">
                </p>

                <p>
                    <label for="issue_description">Mô tả</label>
                    <textarea accesskey="e" class="wiki-edit" cols="60" id="task_description" name="task_description" rows="10"><?php echo $data_task['task_description']; ?></textarea>
                </p>

                <div id="attributes" class="attributes">

                    <div class="splitcontent">
                        <div class="splitcontentleft">
                            <p>
                                <label for="issue_status_id">Trạng thái<span class="required"> *</span></label>
                                <select id="task_status" name="task_status">
                                    <option value="1" <?php if($data_task['task_status'] == 1){ echo "selected";} ?>>Mới</option>
                                    <option value="2" <?php if($data_task['task_status'] == 2){ echo "selected";} ?>>Đang thực hiện</option>
                                    <option value="3" <?php if($data_task['task_status'] == 3){ echo "selected";} ?>>Đã hoàn thành</option>                                    
                                </select>
                            </p>
                            <p>
                                <label for="issue_priority_id">Ưu tiên<span class="required"> *</span></label>
                                <select id="task_priority" name="task_priority">
                                    <option value="1" <?php if($data_task['task_priority'] == 1){ echo "selected";} ?>>Thấp</option>
                                    <option value="2" <?php if($data_task['task_priority'] == 2){ echo "selected";} ?>>Bình thường</option>
                                    <option value="3" <?php if($data_task['task_priority'] == 3){ echo "selected";} ?>>Cao</option>                                    
                                </select>
                            </p>
                            <p>
                                <label for="issue_assigned_to_id">Gán cho</label>
                                <select id="assign_user_id" name="assign_user_id" size="4" multiple="multiple">
                                    <option <?php foreach($data_assign as $assign){if($assign['assign_user_id'] == $_SESSION['user_pm']['user_id']){echo "selected";}} ?> value="<?php echo $_SESSION['user_pm']['user_id']; ?>"><?php echo $_SESSION['user_pm']['fullname'] . " - Chủ dự án"; ?></option>
                                    <?php foreach($data_member as $row){ ?>
                                        <option <?php foreach($data_assign as $assign){if($assign['assign_user_id'] == $row['user_id']){echo "selected";}} ?> value="<?php echo $row['user_id']; ?>"><?php echo $row['fullname'] . " - " . $row['role_name']; ?></option>
                                        <?php } ?>
                                </select>
                            </p>
                            <p>
                                <label for="issue_tracker_id">Giai đoạn<span class="required"> *</span></label>
                                <select id="task_version" name="task_version">
                                    <?php foreach($data_version as $row){ ?>
                                        <option <?php if($data_task['task_version'] == $row['version_id'] ){echo "selected";} ?> value="<?php echo $row['version_id']; ?>"><?php echo $row['version_name']; ?></option>
                                        <?php } ?>
                                </select>
                            </p>
                        </div>

                        <div class="splitcontentright">                            
                            <p>
                                <label for="issue_start_date">Bắt đầu</label>                                
                                <input id="start_date" name="start_date" size="10" value="<?php echo date('d/m/Y',$data_task['task_start_date']); ?>" type="text">
                            </p>
                            <p>
                                <label for="issue_due_date">Hết hạn</label>
                                <input id="end_date" name="end_date" size="10" value="<?php echo date('d/m/Y',$data_task['task_end_date']); ?>" type="text">
                            </p>
                            <p>
                                <label for="issue_estimated_hours">Thời gian ước đoán</label>
                                <input id="task_estimated_time" name="task_estimated_time" size="3" type="text" value="<?php echo $data_task['task_estimated_time']; ?>"> Giờ
                            </p>
                            <p>
                                <label for="issue_done_ratio">Tiến độ</label>
                                <select id="task_percent_done" name="task_percent_done">
                                    <option <?php if($data_task['task_percent_done'] == 0 ){echo "selected";} ?> value="0">0 %</option>
                                    <option <?php if($data_task['task_percent_done'] == 10 ){echo "selected";} ?> value="10">10 %</option>
                                    <option <?php if($data_task['task_percent_done'] == 20 ){echo "selected";} ?> value="20">20 %</option>
                                    <option <?php if($data_task['task_percent_done'] == 30 ){echo "selected";} ?> value="30">30 %</option>
                                    <option <?php if($data_task['task_percent_done'] == 40 ){echo "selected";} ?> value="40">40 %</option>
                                    <option <?php if($data_task['task_percent_done'] == 50 ){echo "selected";} ?> value="50">50 %</option>
                                    <option <?php if($data_task['task_percent_done'] == 60 ){echo "selected";} ?> value="60">60 %</option>
                                    <option <?php if($data_task['task_percent_done'] == 70 ){echo "selected";} ?> value="70">70 %</option>
                                    <option <?php if($data_task['task_percent_done'] == 80 ){echo "selected";} ?> value="80">80 %</option>
                                    <option <?php if($data_task['task_percent_done'] == 90 ){echo "selected";} ?> value="90">90 %</option>
                                    <option <?php if($data_task['task_percent_done'] == 100 ){echo "selected";} ?> value="100">100 %</option>
                                </select>
                            </p>
                        </div>
                    </div>

                    <div class="splitcontent">
                        <div class="splitcontentleft">
                        </div>
                    </div>

                </div>

            </div>

            <!--<p id="watchers_form"><label>Thành viên</label>
            <span id="watchers_inputs">                       
            <?php foreach($data_member as $row){ ?>                                        
                <label class="floating" id="issue_watcher_user_ids_<?php echo $row['user_id']; ?>"><input name="issue[watcher_user_ids][]" type="checkbox" value="<?php echo $row['user_id']; ?>"><?php echo $row['fullname']; ?></label>
                <?php } ?>                               
            </span>
            </p>-->

        </div>

        <input name="commit" type="button" value="Tạo" onclick="update_task(<?php echo $data_task['task_id']; ?>)">    
        <div style="clear:both;"></div>
    </div>
</div>

<?php include "update.js.php"; ?>